#ifndef __NET_BUFFER_H__
#define __NET_BUFFER_H__

#include "net_platform.h"

namespace wel
{
	class CMutableBuffer
	{
	public:
		CMutableBuffer()
			:m_pBuf(NULL)
			,m_size(0)
		{

		}
		CMutableBuffer(char *pBuf, UINT size)
			:m_pBuf(pBuf)
			,m_size(size)
		{

		}

	protected:
		char *m_pBuf;
		UINT  m_size;
	};

	class CConstBuffer
	{
	public:
		CConstBuffer()
			:m_pBuf(NULL)
			,m_size(0)
		{

		}
		CConstBuffer(const char *pBuf, UINT size)
			:m_pBuf(pBuf)
			,m_size(size)
		{

		}

	protected:
		const char *m_pBuf;
		UINT  m_size;
	};

	class CBufferWrapper
	{
	public:
		CBufferWrapper()
			:m_pBuf(NULL)
			,m_size(0)
		{

		}
		CBufferWrapper(char *pBuf, UINT size)
			:m_pBuf(pBuf)
			,m_size(size)
		{

		}

	public:
		CMutableBuffer MutableBuffer()
		{
			return CMutableBuffer(m_pBuf, m_size);
		}

		CConstBuffer ConstBuffer()
		{
			return CConstBuffer(m_pBuf, m_size);
		}

	protected:
		friend UINT BufferSize(const CBufferWrapper &buf);
		friend char* BufferContent(const CBufferWrapper &buf);

		char *m_pBuf;
		UINT  m_size;
	};

	inline UINT BufferSize(const CBufferWrapper &buf)
	{
		return buf.m_size;
	}

	inline char* BufferContent(const CBufferWrapper &buf)
	{
		return buf.m_pBuf;
	}
}

#endif //__NET_BUFFER_H__